<template>
	<view class="f26r">
		<navbar background="background-image: linear-gradient(to right, #2c6739, #99c043);"
			title="消息详情" back @onBack="goBack"
		></navbar>
		<view class="p20r">
			<view class="col080808 foWeiBold f30r backColWhite borRad10r p20r boxSha0a5a12a0Rgb217a226a223a50Per">
				{{optionItem.type == 1 ? optionItem.info.title : optionItem.order_name}}
			</view>
			<view class="col999 f24r mt30r backColWhite borRad10r p20r boxSha0a5a12a0Rgb217a226a223a50Per">
				【{{
					optionItem.type == 1 ? '系统群发' :
					optionItem.type == 2 ? '订单通知' :
					optionItem.type == 3 ? '会员通知' : optionItem.type
				}}】
				<text :class="optionItem.is_read == 1 ? 'colC72d21' : 'col00c260'"
				>
					（{{
						optionItem.is_read == 1 ? '未读' :
						optionItem.is_read == 2 ? '已读' : optionItem.is_read
					}}）
				</text>
				{{optionItem.date}}
			</view>
			<!-- <view class="mt30r col999 backColWhite borRad10r p20r" v-if="optionItem.type == 1">
				商品链接：
				<text class="col1887f5">
					{{optionItem.info.url}}
				</text>
			</view> -->
			<view class="mt30r lh50r backColWhite borRad10r p20r woBrBrAll boxSha0a5a12a0Rgb217a226a223a50Per">
				{{optionItem.type == 1 ? optionItem.info.introduce : optionItem.order_introduce}}
			</view>
			<view class="mt30r backColWhite borRad10r p20r boxSha0a5a12a0Rgb217a226a223a50Per"
				v-if="optionItem.type == 1 && optionItem.info.content"
			>
				<rich-text :nodes="optionItem.info.content"
				></rich-text>
			</view>
		</view>
	</view>
</template>
<script>
import navbar from '@/components/navbar.vue'
import { isMsgRead } from '@/utils/api.js'
import { formatRichText } from "@/utils/utils"
export default {
	components: { navbar },
	data() {
		return {
			optionItem: ''
		}
	},
	onLoad() {
		this.optionItem = uni.getStorageSync('noticeDetail');
		uni.removeStorageSync('noticeDetail');
		console.log(11, this.optionItem)
		if(this.optionItem.info && this.optionItem.info.content) this.optionItem.info.content = formatRichText(this.optionItem.info.content);
		if(this.optionItem.is_read == 1) {
			isMsgRead({
				token: uni.getStorageSync('token'),
				id: this.optionItem.id
			}).then(res => {
				console.log('消息标记已读', res)
			})
		}
	},
	methods: {
		goBack() {
			uni.navigateBack()
		},
		
	}
}
</script>
<style>
</style>